import BaseModel from "../../cfw/mvc/BaseModel";
import User from "../db/User";
import { EventName } from "../../public/Config";

export default class HitMouseMgr extends BaseModel {


    private static ins: HitMouseMgr;

    static instance() {
        if (!this.ins) {
            this.ins = new HitMouseMgr()
        }
        return this.ins;
    }

    protected maxCount: number = 0

    private hitCount: number = 0;

    private overFlag: boolean = false;

    constructor() {
        super();
        this.maxCount = User.instance().getMaxHitCount()
    }

    start(){
        this.hitCount = 0;
        this.overFlag = false;
    }


    isOver() {
        return this.overFlag;
    }

    setOverFlag(f: boolean) {
        this.overFlag = f;
        if (f) {
            if (this.hitCount > this.maxCount) {
                User.instance().setMaxHitCount(this.hitCount)
            }
        }
    }

    getMaxHitCount() {
        return this.maxCount;
    }

    addCount() {
        this.hitCount++;
        this.emit(EventName.UPDATE_CLICK_NUM)

    }

    getHitCount() {
        return this.hitCount;
    }

    getTotalTime() {
        return 15;
    }




}
